#include <iostream>
#include <string>
#include <algorithm>

bool check(const std::string& a) {
    if (std::count(a.begin(), a.end(), '(') == std::count(a.begin(), a.end(), ')')) {
        if (std::count(a.begin(), a.end(), '{') == std::count(a.begin(), a.end(), '}')) {
            if (std::count(a.begin(), a.end(), '[') == std::count(a.begin(), a.end(), ']')) {
                if (std::count(a.begin(), a.end(), '<') == std::count(a.begin(), a.end(), '>')) {
                    return true;
                }
            }
        }
    }
    return false;
}

int main() {
    std::string input;
    std::cout << "Введите последовательность скобок ";
    std::cin >> input;
    if (check(input)) {
        std::size_t n1 = input.find('{');
        std::size_t n2 = input.find('}');
        if (n1 != std::string::npos && n2 != std::string::npos && n1 < n2) {
            std::cout << "true\n";
        } else {
            std::cout << "false\n";
        }

        std::size_t n3 = input.find('(');
        std::size_t n4 = input.find(')');
        if (n3 != std::string::npos && n4 != std::string::npos && n3 < n4) {
            std::cout << "true\n";
        } else {
            std::cout << "false\n";
        }

        std::size_t n5 = input.find('[');
        std::size_t n6 = input.find(']');
        if (n5 != std::string::npos && n6 != std::string::npos && n5 < n6) {
            std::cout << "true\n";
        } else {
            std::cout << "false\n";
        }

        n5 = input.find('<');
        n6 = input.find('>');
        if (n5 != std::string::npos && n6 != std::string::npos && n5 < n6) {
            std::cout << "true\n";
        } else {
            std::cout << "false\n";
        }
    } else {
        std::cout << "false\n";
    }
    return 0;
}

